package com.yuyou.fn.educational.service;

import com.github.wens.framework.service.ISuperService;
import com.github.wens.mybatisplus.plugins.Page;
import com.yuyou.fn.educational.entity.CourseClass;
import com.yuyou.fn.educational.vo.*;
import com.yuyou.fn.platform.permission.DataPermission;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;

import java.util.List;
import java.util.Map;


/**
 *
 * CourseClass 表数据服务层接口
 *
 */
public interface ICourseClassService extends ISuperService<CourseClass,Long> {


    Page<CourseClass> findCourseClassByQueryForPage(CourseClassQueryVo courseClassQueryVo, DataPermission dataPermission , int pageNo, int pageSize);

    Page<CourseClass> findByQueryForPage(List<Long> periodIds,List<Long> busTeamIds,List<Long> gradeIds,CourseClassQueryVo courseClassQueryVo, int pageNo, int pageSize);



    List<CourseClass> findCourseClassList(CourseClassQueryVo courseClassQueryVo, DataPermission dataPermission ,String ...columns);

    List<CourseClass> findCourseClassByQueryForList(CourseClassQueryVo courseClassQueryVo, List<Long> areaTeamIdList,List<Long> busTeamIdList,List<Long> periodIds,List<Long> gradeIdList ,String ...columns);


    CourseClass saveOrUpdateCourseClass(CourseClassSaveOrUpdateVo courseClassSaveOrUpdateVo);


    void saveArrangementRoom(Long classId, Long roomId);

    //设置班级教师并且生成讲次对象
    void saveArrangementTeacher(Long classId, List<Long> teacherIds);


    //报名人数减一
    boolean decreaseRegAmount(Long classId);


    void saveArrangeClassTimeResult(Long classId , List<ArrangeClassTimeResultVo> arrangeClassTimeResultList);


    void changeStatus(List<Long> classIds, Integer status);

    boolean increaseRegAmount(Long classId,Integer nowRegAmount);

    boolean updateCompletedLectureAmount(Long classId, Integer completedLectureAmount);

    void recommendCourseClass(List<Long> classIds, Integer isRecommend);

    Page<CourseClass> findMyTeachingCourseClass(Long teacherId, Long periodId, int pageNo, int pageSize);


    List<CourseClass> findCourseClassByPeriodIdTeacherId(Long periodId , Long teacherId);

    List<CourseClass> findUseCourseClassByPeriodIds(List<Long> periodIds,String ...columns);

    List<CourseClass> suggestCourseClassForTeacher(Long periodId,Long teacherId, int limit);

    void prepareRearrange(Long classId, Integer which);

    void rearrangeTimeForLecture(Long classLectureId, String date, String time, boolean updateAfterLecture);

    void rearrangeTeacherForLecture(Long classLectureId, Long teacherId, boolean updateAfterLecture,String remark);

    void reArrangeTeacherForLectures(Long classLectureId, Long teacherId,String remark);

    void updateTeacherInfo(Long classId);

    Page<CourseClass> findCourseClassByQuery(CourseClassQueryVo courseClassQueryVo, int pageNo, int pageSize);



    void saveClassChange(Long classId, String className, String studyingTime, Long teacherId);


    List<CourseClass> findByClassNo(List<String> classNos);



    List<CourseClass> findSimpByProductIds(List<Long> productIds,String ...columns);

    List<CourseClass> findSimpByProductIdsAndBusTeamIdsAndPeriodId(List<Long> productIds,List<Long> busTeamIds,Long periodId,String...columns);



    List<CourseClass> findSimpByBusTeamIds(List<Long> busTeamIdList,String...columns);

    List<CourseClass> findSimpByBusTeamIdsAndPeriodId(List<Long> busTeamIdList,Long periodId,String...columns);

    List<CourseClass> findByBusTeamIdsAndGradesAndSubjects(List<Long> busTeamIdList,List<Long> gradeIds,List<Long> subjectIds,String ...columns);;


    void updateSenior(Long[] classIds, Long teacherId);

    List<CourseClass> findBaseCourseClassByProductIds(List<Long> productIdList, String ... props );

    List<CourseClass> findBaseCourseClassByBusTeamIds(List<Long> busTeamIdList, String ... props );



    void importCourseClass(List<ImportCourseClassVo> importCourseClassVoList ) throws Exception;

    List<Long> howManySubjectForCampusAndPeriod(Long campusId, Long periodId);

    List<Long> howManyProductForBusTeam(Long busTeamId);

    List<Long> howManyNowProductForBusTeam(Long busTeamId,List<Integer> statusList,Long periodId);


    List<String> howManySubjectIdGradeIdForBusTeam(Long busTeamId);

    List<String> howManyNowSubjectIdGradeIdForBusTeam(Long busTeamId,List<Integer> statusList,Long periodId);

    Page<CourseClass> findCourseClassForRegByQueryForPage(CourseClassQueryVo courseClassQueryVo, int pageNo, int pageSize);


    List<CourseClass> findListByBusTeamIdsPeriodIdsGradeIdsStatuses(List<Long> busTeamIds,List<Long> periodIds,List<Long> gradeIds,List<Integer> statuses,String...columns);


    void updateEndCourseStatus() ;

    void clearTeacher(Long classId);

    void updateCampusNameByCampusId(Long campusId,String campusName);

    void updateRoomNameByRoomId(Long roomId,String roomName);

    /*
    *线上 ：查询可以转班的课程
    *params
    * classId :想转班的课程
    * beginClassLectureNo：开始讲数
    **/
    Page<CourseClass> findCanChangeClassPage(long classId,CourseClassQueryVo courseClassQueryVo,int  beginClassLectureNo, int endClassLectureNo,int pageNo,int pageSize);


    List<BusTeamPeriodGradeClassNumVo> findBusTeamPeriodGradeClassNum(SimpleQueryVo simpleQueryVo, int begin, int pageSize);

    Integer countBusTeamPeriodGradeClassNum(SimpleQueryVo simpleQueryVo);

    void mergeDegree(Long classId);

    /**
    *@Description:
    *@Param: sortedSegmentMap 段次map，  weekMap 星期几map  ，periodSegmentOrWeek:  key periodId , value: 导出星期几， 1导出段次
    *@return:
    *@Author: lzh
    *@date:
    */
    SXSSFWorkbook exportScheduleDataOfTeacher(List<TeacherScheduleVo> teacherScheduleVoList, Map<String,Integer> startClassDateMap, Map<String,Integer> weekMap, Map<Long,Integer> periodSegmentOrWeek);

    /**
    *@Description: 通过一个班级创建初始化的另一个班级
    *@Param:
    *@return: 
    *@Author: lzh
    *@date: 
    */
    void copyInitOtherClassByOne(Long classId);

    List<CourseClass> findCourseClassListWithOutPermission(CourseClassQueryVo courseClassQueryVo,String ...columns);

    boolean decreaseLockAmount(List<Long> classIds);

    boolean increaseLockAmount(List<Long> classIds);

    /**
    *@Description: 统计同类别班级 同期数、同业务组、同年级、同科目、同层级的班级数量（初始化or报名中）
    *@Param: 
    *@return: 
    *@Author: lzh
    *@date: 
    */
    List<CourseClass> findSameClass(long periodId,long busTeamId,long gradeId,long subjectId,int level,String ...columns);

    CourseClass saveClassByFullMessage(FullClassSaveVo fullClassSaveVo);

    List<CourseClass> findClassListByAreaTeamIdPeriodId(long areaTeamId,long periodId,String ...columns);
}